package com.xinfu.newproject.adapter.community;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.xinfu.newproject.R;

import java.util.List;

public class CommunityCityAdapter extends ArrayAdapter<String> {

    public CommunityCityAdapter(Context context, int resource, List<String> cityName) {
        super(context, resource);
        this.mContext = context;
        this.mResId = resource;
        this.cityName = cityName;
    }

    private Context mContext;
    private int mResId;
    private List<String> cityName;


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater)
                mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView;
        final ViewHolder holder;

        if (convertView == null) {
            rowView = inflater.inflate(mResId, null);
            holder = new ViewHolder();
            holder.title = (TextView) rowView.findViewById(R.id.popwindow_item_choose_city_tv);
            rowView.setTag(holder);
        } else {
            rowView = convertView;
            holder = (ViewHolder) rowView.getTag();
        }

        if (position == 0) {
            holder.title.setTextSize(12f);
            holder.title.setTextColor(mContext.getResources().getColor(R.color.gray_9));
            holder.title.setEnabled(false);
        } else {
            holder.title.setTextSize(14f);
            holder.title.setTextColor(mContext.getResources().getColor(R.color.location_color));
            holder.title.setEnabled(true);
        }
        holder.title.setText(cityName.get(position));
        return rowView;
    }


    private class ViewHolder {
        TextView title;
    }


}
